package com.ys168.gam.bean;

import java.net.URL;

import javax.swing.Icon;

import com.ys168.gam.basic.IRenderIcon;
import com.ys168.gam.basic.IRenderText;
import com.ys168.gam.download.DownloadStatus;
import com.ys168.gam.util.ResourceLoader;

/**
 * @author Jason Krebs
 * @since 2015年6月12日
 */
public class JobInfo implements IRenderText, IRenderIcon {

    private int index;
    private URL url;
    private DownloadStatus status;

    public JobInfo(int index, URL url) {
        if (url == null) {
            throw new IllegalArgumentException("Argument 'url' could not be null");
        }

        this.index = index;
        this.url = url;
        this.status = DownloadStatus.UN_STSARTED;
    }

    public URL getUrl() {
        return url;
    }

    public DownloadStatus getStatus() {
        return status;
    }

    public void setStatus(DownloadStatus status) {
        this.status = status;
    }

    public int getIndex() {
        return index;
    }

    @Override
    public String getText() {
        return (index + 1) + " " + url.toString();
    }

    @Override
    public Icon getIcon() {
        return ResourceLoader.getDownloadStatusIcon(status);
    }
}
